package com.server.fallback;

import com.comm.enums.FeignErrorEnum;
import com.server.feignApi.BusinessFeignApi;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2022/8/30
 **/
@Slf4j
@Component
public class BusinessFeignApiFallback implements FallbackFactory<BusinessFeignApi> {
    @Override
    public BusinessFeignApi create(final Throwable throwable) {
        return new BusinessFeignApi() {
            /**
             * 测试business服务
             * @return String
             */
            @Override
            public String testDynamicSlave1(String param) {
                log.error("business 熔断,方法:testDynamicSlave1,参数:{},异常信息:{}",param,throwable);
                return FeignErrorEnum.FEIGN_SERVE_ERROR.getDesc() + "【" + throwable.getMessage() + "】";
            }
        };
    }
}
